package com.skytech.component.monitor.data;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.ArrayList;
import java.util.List;

@Service
public class PM25DataService {
    @Autowired
    private PM25DataDAO pm25DataDAO;


    public List<PM25Data>  listGasMonitorData(){
        String[] areaList= new String[]{"南京", "无锡", "徐州", "常州", "苏州", "南通", "连云港", "淮安", "盐城", "扬州", "镇江", "泰州", "宿迁"};
        List<PM25Data> dataList=new ArrayList<>();
        for (String area:areaList) {
            List<PM25Data> monitorPointList=pm25DataDAO.findByGroupByMonitorPoint(area);
            PM25Data pm25DataCity=pm25DataDAO.findByAreaOrderByCrawlingTime(area);
            dataList.add(pm25DataCity);
            if(!monitorPointList.isEmpty()){
                for (PM25Data monitorPoint:monitorPointList) {
                    PM25Data pm25Data=pm25DataDAO.findByMonitorPointOrderByCrawlingTime(monitorPoint.getArea(),monitorPoint.getMonitorPoint());
                    if(null!=pm25Data){
                        dataList.add(pm25Data);
                    }

                }
            }

        }
        return dataList;
    }
}
